//priority 48
/**
 * 随机词条的基类实现了怪物随机词条的函数
*/
function RandomEntry(name) {
    BaseEntry.call(this, name)
}
// 建立原型链
RandomEntry.prototype = Object.create(BaseEntry.prototype);
RandomEntry.prototype.constructor = RandomEntry;

//数字转化成罗马文字
RandomEntry.prototype.intToRoman = function (num) {
    let map = {
        1: 'I',
        5: 'V',
        10: 'X',
        50: 'L',
        100: 'C',
        500: 'D',
        1000: 'M'
    }
    // 标识位数
    let digits = 1
    // 结果
    let result = ''
    while (num) {
        let current = num % 10
        if (current < 4) {
            result = map[digits].repeat(current) + result
        } else if (current === 4) {
            result = map[digits] + map[digits * 5] + result
        } else if (current > 4 && current < 9) {
            result = map[digits * 5] + map[digits].repeat(current - 5) + result
        } else {
            result = map[digits] + map[digits * 10] + result
        }
        digits *= 10
        num = Math.trunc(num / 10)
    }
    return result
};

//获取类的本地化键值，arguments代表不定长参数
RandomEntry.prototype.getText = function () {
    return Text.translate("rpg.monster.entry." + this.getName() + ".text", this.intToRoman(arguments[0]))
};

//怪物加载时候对怪物名称的修改
RandomEntry.prototype.ChangeName = function (nbt, name, monster, level) {
    name.push(" ", this.getText(level))//放在名字后面
}

//词条能否应用
RandomEntry.prototype.CanUse = function (nbt, monster) {
    return true
}
//怪物等级花费
RandomEntry.prototype.LevelCost = function (nbt, monster, level) {
    return 1
}

// var a = new RandomEntry("type").init()
// //注册技能自身
// global.EntryHelper.RegisterEntry(a).AddToEntryGroup(a, "type_group")